package com.zhentao.model.pojo.user.yichang.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;
import java.math.BigInteger;

public class BigIntToStringSerializer extends StdSerializer<Number> {
    public BigIntToStringSerializer() {
        super(Number.class);
    }

    @Override
    public void serialize(Number value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        if (value instanceof BigInteger) {
            gen.writeString(value.toString());
        } else if (value instanceof Long) {
            gen.writeString(Long.toString(value.longValue()));
        } else {
            // 可以根据需要添加对其他类型的处理
            gen.writeString(value.toString());
        }
    }
}
